package customize

import (
	"gitcode.com/G-YT/baoyou/server/model/cms"
)

type Efficacy struct {
	ID   uint   `json:"id" form:"id" gorm:"column:id;comment:id;"`
	Name string `json:"name" gorm:"column:name;comment:功效名称"`
}

// EfficacyArticle 功效文章
type EfficacyArticle struct {
	EfficacyID   uint         `json:"efficacy_id" from:"efficacy_id" gorm:"column:efficacy_id;"`
	ArticleID    uint         `json:"article_id" gorm:"column:article_id;"`
	Type         string       `json:"type" gorm:"column:type;"`
	Efficacy     *Efficacy    `json:"-" form:"-" gorm:"->;foreignKey:EfficacyID;references:ID;"` // 关联功效
	AudioArticle *cms.Article `json:"-" form:"-" gorm:"->;foreignKey:ArticleID;references:ID;"`  // 关联音频文章
	VideoArticle *cms.Article `json:"-" form:"-" gorm:"->;foreignKey:ArticleID;references:ID;"`  // 关联视频文章
	TextArticle  *cms.Article `json:"-" form:"-" gorm:"->;foreignKey:ArticleID;references:ID;"`  // 关联文本文章
}

func (Efficacy) TableName() string { return "by_efficacy" }

func (EfficacyArticle) TableName() string {
	return "by_efficacy_article"
}
